
	<?php
		if(empty($_GET['type'])) {
			echo "项目参数错误";
			exit;
		}
		require_once("connect_sql.php");
			
		//project table
		$type = $_GET['type'];
	?>
	
	<?php if($type == 'author' || $type == 'rfpa' || $type == 'classK' || $type == 'function') {
		$sql = sprintf('select * from %s order by id', $type);
		$result = mysql_query($sql);
		if(!$result) echo mysql_error();
		$i = 0;
		
		echo '<table class="table3">';
		while($row = mysql_fetch_array($result)) {
			$id = $row['id'];
			$name = $row['name'];
			if(($i % 4) == 0) {
				echo '<tr>';
			}
			printf('<td class="propertyTd">%s</td>', $name);
			$i++;
			
			if(($i % 4) == 0) {
				echo '</tr>';
				$i = 0;
			}
		}
		if($i == 0)
			echo '<tr>';
		printf('<td class="propertyTd"><button class="addBtn" id="addOne"></button></td>');
		echo '</tr>';
		echo '</table>';
		echo '<br/>';
		echo '<button class="button saveBtn" id="save" onClick="onSaveClicked(\''.$type.'\')">保存</button>';
	} else if($type == 'customer') {
		$sql = sprintf('select * from %s order by id', $type);
		$result = mysql_query($sql);
		if(!$result) echo mysql_error();
		$i = 0;
		
		echo '<table class="table3">';
		while($row = mysql_fetch_array($result)) {
			$id = $row['id'];
			$name = $row['name'];
			if(($i % 4) == 0) {
				echo '<tr>';
			}
			printf('<td class="propertyTd">%s</td>', $name.'-'.$row['abbreviate']);
			$i++;
			
			if(($i % 4) == 0) {
				echo '</tr>';
				$i = 0;
			}
		}
		if($i == 0)
			echo '<tr>';
		printf('<td class="propertyTd"><button class="addBtn" id="addOne"></button></td>');
		echo '</tr>';
		echo '</table>';
		echo '<br/>';
		echo '<button class="button saveBtn" id="save" onClick="onSaveClicked(\''.$type.'\')">保存</button>';
	} else if($type == 'camera' || $type == 'lcd') {
		$sql = sprintf('select distinct size from %s order by size', $type);
		$result = mysql_query($sql);
		if(!$result) echo mysql_error();
		echo '<table class="table3">';
		while($row = mysql_fetch_array($result)) {
			echo '<tr><td class="propertyCap" colspan=4>'.$row['size'].'</td></tr>';
			$sql = sprintf('select * from %s where size="%s" order by name', $type, $row['size']);
			$ret = mysql_query($sql);
			if(!$ret) echo mysql_error();
			$i = 0;
			while($r = mysql_fetch_array($ret)) {
				if(($i % 4) == 0) {
					echo '<tr name="'.$row['size'].'">';
				}
				printf('<td class="propertyTd">%s</td>', $r['name']);
				$i++;
				
				if(($i % 4) == 0) {
					echo '</tr>';
					$i = 0;
				}
			}
			if($i == 0)
				echo '<tr name="'.$row['size'].'">';
			printf('<td class="propertyTd"><button class="addBtn" id="addOne"></button></td>');
			echo '</tr>';
		}
		echo '</table>';
		echo '<br/>';
		echo '<button class="button saveBtn" id="save" onClick="onSaveClicked(\''.$type.'\')">保存</button>';
	} else if($type == 'platform') {
		$sql = sprintf('select * from %s order by id', $type);
		$result = mysql_query($sql);
		if(!$result) echo mysql_error();
		$i = 0;
		
		echo '<table id="platform" class="table3">';
		while($row = mysql_fetch_array($result)) {
			$id = $row['id'];
			$name = $row['name'];
			if(($i % 4) == 0) {
				echo '<tr>';
			}
			printf('<td class="propertyTd">%s</td>', $name);
			$i++;
			
			if(($i % 4) == 0) {
				echo '</tr>';
				$i = 0;
			}
		}
		if($i == 0)
			echo '<tr>';
		printf('<td class="propertyTd"><button class="addBtn" id="platAdd"></button></td>');
		echo '</tr>';
		echo '</table>';
		echo '<br/>';
		echo '<table id="platTable" class="table3" hidden>';
		echo '<tr><td><label>平台名称：</label><input type="text" id="name" autocomplete="off"/></td></tr>';
		echo '<tr><td><label>代码包名：</label><input type="text" id="code" autocomplete="off"/></td></tr>';
		echo '<tr><td><label>下载工具：</label><input type="text" id="downloadTool" autocomplete="off" list="tools">';
		$result = mysql_query('select distinct downloadTool from platform order by downloadTool');
		if(!$result) echo mysql_error();
		echo '<datalist id="tools">';
		while($row = mysql_fetch_array($result)) {
			printf('<option value="%s"/>', $row['downloadTool']);
		}
		echo '</datalist>';
		echo '</input></td></tr>';
		echo '</table>';
		echo '<br/>';
		echo '<button class="button saveBtn" id="save" onClick="onPlatSaveClicked()">保存</button>';
	} else if($type == 'platformDetail') {
		$sql = sprintf('select * from platform where name="%s"', $_GET['name']);
		$result = mysql_query($sql);
		if(!$result) echo mysql_error();
		
		$name = "";
		$code = "";
		$downloadTool = "";
		while($row = mysql_fetch_array($result)) {
			$name = $row['name'];
			$code = $row['code'];
			$downloadTool = $row['downloadTool'];
		}
		echo $name.','.$code.','.$downloadTool;
	}
	?>
	